/*
 * CS_ATTACK_START.cpp
 *
 *  Created on: 2013. 5. 21.
 *      Author: the2
 */

#include "../../User.h"
#include "CS_ATTACK_START.h"

#include "../../NLogic/Static.h"
#include "../../NLogic/Battle.h"

namespace ProjectZ { namespace NCommand { namespace NAction {

void CS_ATTACK_START::OnExecute(User * pUser, ::Network::Packet * pPacket)
{
	/*
	 * 공격시작 패킷
			CS_ATTACK_START	0x0406	7
			4	unsigned int	GID
			2	posx	x 좌표
			2	posy	y 좌표
			1	char	콤보카운트
			2	degree	방향벡터정보
			1	char	몬스터여부 (0 : 주인공 1: 몬스터 2: 주인공소환, 3: 몬스터 소환)

공격시작 알림
			SN_ATTACK_START	0x0407	7
			4	unsigned int	GID
			2	posx	x 좌표
			2	posy	y 좌표
			1	char	콤보카운트
			2	degree	방향벡터정보
			1	char	몬스터여부 (0 : 주인공 1: 몬스터 2: 주인공소환, 3: 몬스터 소환)
	 *
	 */

	PREPARE_PACKET;

	static int attack_start_count = 0;


	unsigned int GID = 0;
	int16_t x = 0;
	int16_t y = 0;
	int8_t combo = 0;
	int16_t degree = 0;
	int8_t ismonster = 0;

	* pPacket >> GID >> x >> y >> combo >> degree >> ismonster;
	attack_start_count++;

	NLogic::Space * pSpace = pUser->GetSpace();
	if (NULL == pSpace)
	{
		return;
	}

	if( ismonster == false )
	{
		// Position
//		pUser->player_info.x = x;
//		pUser->player_info.y = y;
		pUser->GetBattle()->GetData().x = x;
		pUser->GetBattle()->GetData().y = y;

		pUser->GetBattle()->GetData().combo_max = combo;
	}

	::Network::Packet * pNoti = ::Network::GETPACKETPOOL()->SEND_NEW();
	* pNoti << GID << x << y << combo << degree << ismonster;
	pNoti->MakePacket(CMD_SC_ATTACK_START);

	pSpace->SendAllExceptMe(pNoti, pUser);
}

} /*NAction*/ } /*NCommand*/ } /*ProjectZ*/
